<template>
	<view class="">
		<view class="topimg mainpadding">
			<view class="mainpadding ffffff radius" style="padding:  60rpx 40rpx 80rpx;position: relative;">
				<view class=" flexcolumn">
					<view class="flexleft">
						<view class="xiaohei " style="font-size: 34rpx;">累计业绩(元)</view>
					</view>
					<view class="margin_top2 flexleft">
						<view class="xiaohei bold" style="font-size: 50rpx;">{{userInfo?userInfo.total_user_yj : 0}}</view>
					</view>
				</view>
				<view class="xiaobai smalltext yjcx flexleft" @click="jumpurl('/pages/index/yeji')">
					<view class="">业绩查询</view>
					<u-icon name="arrow-right" color="#fff" size="10"></u-icon>
				</view>
				
				<view class="margin_top4 flexbetween">
					<view class="flexcolumn" style="width: 45%;">
						<view class="xiaohei sanshier">团队当月业绩(元)</view>
						<view class="xiaohei strongtext margin_top2 bold" style="font-size: 35rpx;">{{userInfo?userInfo.total_mouth_user_yj : 0}}</view>
					</view>
					<!-- <view class="line"></view> -->
					<view class="flexcolumn" style="width: 45%;">
						<view class="xiaohei sanshier">代理人数(个)</view>
						<view class="xiaohei strongtext margin_top2 bold" style="font-size: 35rpx;">{{userInfo?userInfo.team_num :0}}</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="mainpadding2">
			<!-- <view class="" @click="jumpurl('/pages/index/gonggao')">
				<u-notice-bar :text="text1" direction="column" bgColor="#f8f8f8"></u-notice-bar>
			</view> -->
			<view class="mainpadding flexbetween ffffff radius" @click="jumpurl('/pages/index/gonggao')">
				<view class="flexleft">
					<view class="gonggao smalltext margin_right2 xiaobai">公告</view>
					<view class="xiaohei ershiba yhxk" style="width: 450rpx;">{{text1[0]}}</view>
				</view>
				<u-icon name="arrow-right" color="#999" size="14"></u-icon>
			</view>
			<view class="flexbetween margin_top">
				<view class="sanshier xiaohei bold">分润统计</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="" style="width: 47%;">
					<view class="flexleft fenrun1">
						<image src="../../static/image/system/left.png" mode=""></image>
						<view class="titletext bold" style="color: #FF8F43;">当月分润</view>
					</view>
					<view class="itemcontent" @click="jumpurl('/pages/index/fenrunjl?type=0')">
						<view class="xiaohui strongtext">金额(元)</view>
						<view class="margin_top2 xiaohei titletext bold" style="font-size: 40rpx;">{{userInfo?userInfo.lastmouth_frprice : 0}}</view>
					</view>
				</view>
				<view class="" style="width: 47%;">
					<view class="flexleft fenrun2">
						<image src="../../static/image/system/right.png" mode=""></image>
						<view class="titletext bold" style="color: #3B50FF;">累计分润</view>
					</view>
					<view class="itemcontent" @click="jumpurl('/pages/index/fenrunjl?type=1')">
						<view class="xiaohui strongtext">金额(元)</view>
						<view class="margin_top2 xiaohei titletext bold" style="font-size: 40rpx;">{{userInfo?userInfo.total_frprice : 0}}</view>
					</view>
				</view>
			</view>
			<view class="" @click="jumpurl('/pages/index/yaoqinghy')">
				<image src="@/static/image/system/yqhyhome.png" style="width: 100%;height: 200rpx;" mode=""></image>
			</view>
			<view class="ffffff mainpadding_top flexbetween radius" style="padding: 10rpx;">
				<view class="flexleft itemimgbox" @click="jumpurl('/pages/index/shangchneg')">
					<image src="@/static/image/system/left1.png" mode=""></image>
					<view class="">
						<view class="xiaohei bold sanshier">聚合商城</view>
						<view class="xiaohui smalltext margin_top1 flexleft">
							<view class="">去查看</view>
							<u-icon name="arrow-right" color="#999" size="10"></u-icon>
						</view>
					</view>
				</view>
				<view class="flexleft itemimgbox" 
					@click="jumpurl('/pages/index/shangxuey')">
					<image src="@/static/image/system/right1.png" mode=""></image>
					<view class="">
						<view class="xiaohei bold sanshier">收单学院</view>
						<view class="xiaohui smalltext margin_top1 flexleft">
							<view class="">去查看</view>
							<u-icon name="arrow-right" color="#999" size="10"></u-icon>
						</view>
					</view>
				</view>
			</view>
			<!-- <view class="flexleft margin_top itemimgbox2" @click="jumpurl('/pages/index/shangxuey')">
				<image src="@/static/image/system/sdxy.png" mode=""></image>
				<view class="flexcolumn">
					<view class="xiaobai bold" style="font-size: 40rpx;">收单学院</view>
					<view class="xiaobai bold strongtext">点击查看</view>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				text1: [],
				userInfo:{},
				is_login:false,
				paraString:""
			}
		},
		onLoad() {
			this.paraString = window.location.href //还可以  window.location.search.substring()
			let invite_code = this.getQueryVariable('invite_code') //code是url后面带的
			if(invite_code){
				uni.setStorageSync("invite_code",invite_code)
			}
			this.getgonggao()
		},
		onShow() {
			this.is_login = httpRequest.checkIsLogin();
			if (this.is_login) {
				this.init()
			} else {
				this.userInfo = null
			}
		},
		methods: {
			jumpurl(url){
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/applogin"
					})
					return false
				}
				uni.navigateTo({
					url
				})
			},
			getQueryVariable(variable) {
				var query = this.paraString.slice(0,-2);
				var rooms = query.split('?');
				for (var i = 0; i < rooms.length; i++) {
					var pair = rooms[i].split('=');
					if (pair[0] == variable) {
						return (pair[1].split('&'))[0]
					}
				}
				//或者拼接&后面的值
				var vars = query.split('&')
				for (var i = 0; i < vars.length; i++) {
					var pair = vars[i].split('=')
					if (pair[0] == variable) {
						return pair[1]
					}
				}
			},
			init() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					if (res.code == 1) {
						this.userInfo = res.data
					} else {
						this.userInfo = null
					}
			
				})
			},
			getgonggao() {
				httpRequest.request('/api/index/noticeIndex', 'POST', {
					page: 1,
					limit: 12,
				}, false, false, true).then(res => {
					let arr = []
					res.data.data.forEach(item => {
						arr.push(item.name)
					})
					this.text1 = arr
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.gonggao{
		padding: 7rpx 20rpx;
		border-radius: 10rpx;
		background-color: #ff8f43;
	}
	.fenrun1{
		border-radius: 20rpx;
		background: linear-gradient( 270deg, #FFDBC1 0%, #FFEEE4 100%);
		padding: 20rpx 20rpx 50rpx;
		box-sizing: border-box;
		image{
			width: 45rpx;
			height: 45rpx;
			margin-right: 20rpx;
		}
	}
	.fenrun2{
		border-radius: 20rpx;
		background-color: #e6e8fa;
		padding: 20rpx 20rpx 50rpx;
		box-sizing: border-box;
		image{
			width: 45rpx;
			height: 45rpx;
			margin-right: 20rpx;
		}
	}
	.topimg{
		background-image: url("@/static/image/system/topimg.png");
		background-size: 100% 300rpx;
		background-repeat: no-repeat;
	}
	.line {
		width: 2rpx;
		background-color: #3B50FF;
		height: 50rpx;
	}

	.itemcontent {
		position: relative;
		top: -30rpx;
		background-color: #fff;
		width: 100%;
		border-radius: 20rpx;
		padding: 30rpx 20rpx;
		box-sizing: border-box;
	}

	.itemimgbox {
		width: 48%;
		box-sizing: border-box;
		image {
			width: 150rpx;
			height: 150rpx;
		}
	}

	.itemimgbox2 {
		background-color: #3B50FF;
		border-radius: 10rpx;
		width: 100%;
		padding: 20rpx 40rpx;
		box-sizing: border-box;

		image {
			width: 150rpx;
			height: 150rpx;
			margin-right: 150rpx;
		}
	}
	.yjcx{
		line-height: 20rpx;
		position: absolute;
		right: 0;
		top: 100rpx;
		padding: 10rpx 10rpx 10rpx 20rpx;
		background-color: #3B50FF;
		border-radius: 50rpx 0 0 50rpx;
	}
</style>